/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import bookmaker.HibernateUtil;

/**
 *
 * @author Maciek
 */
public class Market {

    private long id;
    private String name;
    private double odds_home;
    private double odds_draw;
    private double odds_away;
    private Game game;
    private Session session;


    public String dodaj() {
        try {
            SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
            setSession(sessionFactory.openSession());
            Transaction tx = getSession().beginTransaction();
            getSession().save(this);
            tx.commit();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            getSession().close();
        }
        return "ok";
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the odds_home
     */
    public double getOdds_home() {
        return odds_home;
    }

    /**
     * @param odds_home the odds_home to set
     */
    public void setOdds_home(double odds_home) {
        this.odds_home = odds_home;
    }

    /**
     * @return the odds_draw
     */
    public double getOdds_draw() {
        return odds_draw;
    }

    /**
     * @param odds_draw the odds_draw to set
     */
    public void setOdds_draw(double odds_draw) {
        this.odds_draw = odds_draw;
    }

    /**
     * @return the odds_away
     */
    public double getOdds_away() {
        return odds_away;
    }

    /**
     * @param odds_away the odds_away to set
     */
    public void setOdds_away(double odds_away) {
        this.odds_away = odds_away;
    }

    /**
     * @return the game
     */
    public Game getGame() {
        return game;
    }

    /**
     * @param game the game to set
     */
    public void setGame(Game game) {
        this.game = game;
    }

    /**
     * @return the session
     */
    public Session getSession() {
        return session;
    }

    /**
     * @param session the session to set
     */
    public void setSession(Session session) {
        this.session = session;
    }
    
}
